1 00:00:00,480 --> 00:00:05,640 So this whole time that we've been learning the Lua language and doing these practice problems, you've 2 00:00:05,640 --> 00:00:08,220 been creating something called algorithms. 3 00:00:08,550 --> 00:00:14,460 A simple definition for an algorithm is a set of instructions for completing a task or solving a problem. 4 00:00:14,460 --> 00:00:15,540 That's all they are. 5 00:00:15,840 --> 00:00:20,400 When you follow recipes in a cookbook to make food, you're following an algorithm. 6 00:00:20,400 --> 00:00:25,140 When you're following the process to insert your keys, start your car and shift into drive. 7 00:00:25,170 --> 00:00:26,340 That's an algorithm. 8 00:00:26,550 --> 00:00:32,100 In this video, I want to briefly talk about what you should focus on when programming in order to efficiently 9 00:00:32,100 --> 00:00:34,380 solve problems and create algorithms. 10 00:00:34,410 --> 00:00:39,450 The very first step before creating an algorithm is to figure out what problem you're trying to solve. 11 00:00:39,570 --> 00:00:44,250 Maybe you want to figure out how to create a guy that plays a click sound when a button is pressed. 12 00:00:44,400 --> 00:00:48,210 Or maybe you want to animate a player's character when they do something like fire a gun. 13 00:00:48,240 --> 00:00:52,080 Whatever it is, the first step you want to do is identify the problem. 14 00:00:52,410 --> 00:00:56,280 The next step is to start outlining possible ways to solve the problem. 15 00:00:56,280 --> 00:00:58,800 And you may not know exactly how to fix it. 16 00:00:58,800 --> 00:01:03,820 Like perhaps you don't know how to execute a block of code when a player clicks on a button. 17 00:01:03,820 --> 00:01:08,800 But all you need to do is make that rough outline that basically says, okay, when a player clicks 18 00:01:08,800 --> 00:01:13,870 this button, I execute a block of code to perform an action based on the button that is clicked. 19 00:01:13,960 --> 00:01:18,070 I may not know how to do that right now, but I do know that I have to do it later. 20 00:01:18,280 --> 00:01:23,140 Once you get all your steps defined, you want to make sure that these steps, these instructions solve 21 00:01:23,140 --> 00:01:24,010 your problem. 22 00:01:24,010 --> 00:01:29,530 If they do, then you'll start researching on how to execute these steps, like research, how to connect 23 00:01:29,530 --> 00:01:33,640 a function to an event, like when a player clicks on a button and so on. 24 00:01:33,910 --> 00:01:38,980 Once you do that, then you start to build your algorithm, start designing it and implementing all 25 00:01:38,980 --> 00:01:40,540 the stuff you learned prior. 26 00:01:40,570 --> 00:01:45,760 Check to make sure that the algorithm is solving your problem and that you're using the right syntax 27 00:01:45,760 --> 00:01:48,700 and that the logical flow makes sense. 28 00:01:48,850 --> 00:01:53,410 Once you finally complete it, then you can start testing your algorithm to see if it works. 29 00:01:53,410 --> 00:01:58,600 And if it doesn't, you can start debugging it to get the algorithm into a state where it's fully working 30 00:01:58,600 --> 00:01:59,950 and solving your problem. 31 00:02:00,510 --> 00:02:05,370 Then the last step is to document your algorithm, write down comments in your scripts, to remind you 32 00:02:05,370 --> 00:02:10,590 and other developers reading the code what a specific part of it is doing that may seem confusing. 33 00:02:10,770 --> 00:02:16,830 Don't ever over comment your code, but do it to where it's concise and doesn't miss any important details. 34 00:02:17,160 --> 00:02:22,560 Now that, my friend, is the basic process of creating algorithms in your code, if you follow these 35 00:02:22,560 --> 00:02:26,550 steps, solving problems you face when making games will be a lot easier.